<!-- 用户页面 -->
<template>
    <p>用户ID为：{{ id }}</p>
</template>

<script setup>
import { ref } from "vue";
import { useRoute, onBeforeRouteLeave } from "vue-router";

const route = useRoute()

const id = ref(null)

id.value = route.params.id

onBeforeRouteLeave((to, from, next) => {
    alert('您正在离开用户页面!')
    next()
})

</script>